#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>


#define PATHNAME "."
#define PROID 10




// 创建一个消息队列， 打印消息队列ID

int main(int argc, char const *argv[])
{

    key_t key = ftok(PATHNAME, PROID);
    if (key == -1) {
        perror("ftok errror");
        exit(EXIT_FAILURE);
    }
    // 创建messageID
    int msgid = msgget(key, IPC_CREAT | 0666);
    printf("msg id = %d\n", msgid);


    //删除队列
    int ret = msgctl(msgid, IPC_RMID, NULL);
    if (ret == -1) {
        perror("msgctl error");
        exit(EXIT_FAILURE);
    }
    return 0;
}
